{% extends "base/admin.html" %}

{% block title %}用户管理{% endblock %}

{% block head %}
    <!-- Data Tables -->
    <link href="/static/admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
{% endblock %}

{% block content %}
        {% set data = g.api.user_get_all().data %}
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>用户管理</h5><small></small>
                    </div>
                    <div class="ibox-content">
                        <table class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                                <tr>
                                    <th>UID</th>
                                    <th>用户名</th>
                                    <th>头像</th>
                                    <th>别名</th>
                                    <th>性别</th>
                                    <th>邮箱</th>
                                    <th>加入时间</th>
                                    <th>是否作者</th>
                                    <th>是否管理员</th>
                                    <th>动作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for user in data %}
                                <tr valign="middle" align="center">
                                    <td>{{ user.id }}</td>
                                    <td>{{ user.username }}</td>
                                    <td>{% if user.avatar %}<img src="{{ user.avatar }}" width="60px">{% endif %}</td>
                                    <td>{{ user.cname }}</td>
                                    <td>{{ user.gender }}</td>
                                    <td>{{ user.email }}</td>
                                    <td>{{ user.time }}</td>
                                    <td>{% if user.isAuthor in ('true', 'True', True) %}是{% else %}否{% endif %}</td>
                                    <td>{% if user.isAdmin in ('true', 'True', True) %}是{% else %}否{% endif %}</td>
                                    <td>
                                        {% if user.isAuthor in ('true', 'True', True) %}<a class="btn btn-info btn-rounded" href="buttons.html#">取消作者</a>{% else %}<a class="btn btn-info btn-rounded" href="buttons.html#">设置作者</a>{% endif %}<br>
                                        {% if user.isAdmin in ('true', 'True', True) %}<a class="btn btn-danger btn-rounded" href="buttons.html#">取消管理</a>{% else %}<a class="btn btn-danger btn-rounded" href="buttons.html#">设置管理</a>{% endif %}<br>
                                        <a class="btn btn-danger btn-rounded" href="buttons.html#">删除用户</a><br>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
{% endblock %}

{% block script %}
    <!-- Data Tables -->
    <script src="/static/admin/js/plugins/dataTables/jquery.dataTables.js"></script>
    <script src="/static/admin/js/plugins/dataTables/dataTables.bootstrap.js"></script>
    <!-- Page-Level Scripts -->
    <script>
        $(document).ready(function () {
            $('.dataTables-example').dataTable();

            /* Init DataTables */
            var oTable = $('#editable').dataTable();
        });
    </script>

{% endblock %}
